(function(vc){
    vc.extends({
        propTypes: {
           emitChooseShop:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseShopInfo:{
                shops:[],
                _currentShopName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseShop','openChooseShopModel',function(_param){
                $('#chooseShopModel').modal('show');
                $that._refreshChooseShopInfo();
                $that._loadAllShopInfo(1,10,'');
            });
        },
        methods:{
            _loadAllShopInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('shop.listShops',
                             param,
                             function(json){
                                var _shopInfo = JSON.parse(json);
                                $that.chooseShopInfo.shops = _shopInfo.shops;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseShop:function(_shop){
                if(_shop.hasOwnProperty('name')){
                     _shop.shopName = _shop.name;
                }
                vc.emit($props.emitChooseShop,'chooseShop',_shop);
                vc.emit($props.emitLoadData,'listShopData',{
                    shopId:_shop.shopId
                });
                $('#chooseShopModel').modal('hide');
            },
            queryShops:function(){
                $that._loadAllShopInfo(1,10,$that.chooseShopInfo._currentShopName);
            },
            _refreshChooseShopInfo:function(){
                $that.chooseShopInfo._currentShopName = "";
            }
        }

    });
})(window.vc);
